<template>
	<view  class="page"  :style="'height:' + height + 'rpx'">
		<!-- <u-navbar :is-back="false" title="　" :border-bottom="false">
			<view class="u-flex u-row-right" style="width: 100%;">
				<view class="camera u-flex u-row-center">
					<u-icon name="camera-fill" color="#000000" size="48"></u-icon>
				</view>
			</view>
		</u-navbar> -->
		<view class="u-flex user-box u-p-l-30 u-p-r-20 u-p-b-30">
			<view class="u-m-r-10">
				<u-avatar :src="avatarUrl" style="position: relative;top: 22rpx;" size="140" mode="square"></u-avatar>
			</view>
			<view class="u-flex-1">
				<view class="u-font-18 u-p-b-20">{{nickName}}</view>
				<!-- <view class="u-font-14 u-tips-color">微信号:helang_uView</view> -->
			</view>
			<!-- <view class="u-m-l-10 u-p-10">
				<u-icon name="scan" color="#969799" size="28"></u-icon>
			</view>
			<view class="u-m-l-10 u-p-10">
				<u-icon name="arrow-right" color="#969799" size="28"></u-icon>
			</view> -->
		</view>

		<!-- <view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="rmb-circle" title="支付"></u-cell-item>
			</u-cell-group>
		</view> -->

		<view class="u-m-t-20">
			<u-cell-group>
				<u-cell-item icon="setting" title="推送设置" @click="toPushSetingPage"></u-cell-item>
				<u-cell-item icon="map" title="切换校区" @click="toUpdateCampus"></u-cell-item>
				<!-- <u-cell-item icon="reload" title="刷新课表" @click="updateCourse"></u-cell-item> -->
				<u-cell-item icon="fingerprint" title="更新密码" @click="toPasswordChangePage"></u-cell-item>
				<!-- <u-cell-item icon="edit-pen" title="我的发布" @click="toMyPublish()"></u-cell-item> -->
				<!-- <u-cell-item icon="coupon" title="卡券"></u-cell-item>
				<u-cell-item icon="heart" title="关注"></u-cell-item> -->
				<button open-type="contact">
					<u-cell-item >
						<view slot="title" class="u-slot-title">
							<text class="iconfont icon-kefufenxiermaikefu" style="margin-right: 10rpx;"></text>
							<text>联系客服</text>
						</view>
					</u-cell-item>
				</button>
				<u-cell-item icon="zhuanfa" title="分享小程序" @click="toShareMini"></u-cell-item>
			</u-cell-group>
		</view>
		<!-- <tickTip style="bottom:80rpx;"></tickTip> -->


		<view class="textcss">
			<p>版权所有 © 2021 仲园课程表开发组</p>
		</view>
	</view>
</template>

<script>
	import tickTip from "@/components/tickTip/tickTip.vue"
	export default {
		data() {
			return {
				pic: 'https://uviewui.com/common/logo.png',
				show: true,
				nickName: '',
				avatarUrl: '',
				height: 0
			}
		},
		created() {
			let that = this;
			uni.getSystemInfo({
				success: function(res) {
					let pxToRpxScale = 750 / res.windowWidth;
					that.height = res.windowHeight * pxToRpxScale;
				}
			});
		},
		onLoad() {
			let userInfo = uni.getStorageSync("userInfo")
			this.nickName = userInfo.nickName
			this.avatarUrl = userInfo.avatarUrl
		},
		onReady() {},
		methods: {
			toUpdateCampus() {
				console.log('@@@@@@@@@')
				uni.navigateTo({
					url: '../../page_mine/updateCampus/updateCampus'
				})
			},
			toPasswordChangePage() {
				uni.navigateTo({
					url: '../../page_mine/passwordChange/passwordChange'
				})
			},
			toMyPublish(){
				uni.navigateTo({
					url: '../../page_mine/myPublish/myPublish'
				})
			},
			toPushSetingPage() {
				uni.navigateTo({
					url: '../../page_mine/pushSeting/pushSeting'
				})
			},
			toAttentionOffical() {
				uni.navigateTo({
					url: '../../page_mine/attentionOfficial/attentionOfficial'
				})
			},
			toShareMini() {
				uni.navigateTo({
					url: '../../page_mine/shareMini/shareMini'
				})
			},
			updateCourse() {
				let vm = this
				let header = new Object()
				header.Authority = uni.getStorageSync("Authority")
				uni.showModal({
					title: '确定重新导入课表吗？这可能需要5分钟，且您添加的课程将丢失。',
					confirmText: '确定',
					cancelText: '取消',
					async success(i) {
						if (i.confirm) {
							getApp().globalData.successPa == false
							uni.showLoading({
								title: '请稍等...',
								mask: true
							});
							let res = await getApp().UniRequest("/authority/info/updateCourseData", "Get", "",
								header)
							if (res.code == 20000) {
								// uni.hideLoading()
								let vm = this
								let intervalId = setInterval(async function() {
									let header = new Object()
									header.Authority = uni.getStorageSync("Authority")

									if (header.Authority) {

										let paRes = await getApp().UniRequest(
											"/authority/info/successPa", "Get", "", header)
										if (paRes.code == 20000) {
											getApp().globalData.successPa = true
											uni.removeStorageSync('timetables'); //清除旧缓存
											clearInterval(intervalId)
											uni.hideLoading()
										}
									}

								}, 1000)
							} else {
								uni.showToast({
									title: '网络错误，请稍后再试。',
									icon: 'error'
								})
								uni.hideLoading()
							}
						}
					}
				})
			}
		},
		components: {
			tickTip
		}
	}
</script>

<style lang="scss">
	.page {
		background-color: #ededed;
		position: relative;
		.camera {
			width: 54px;
			height: 44px;
		
			&:active {
				background-color: #ededed;
			}
		}
		
		.user-box {
			background-color: #fff;
		}
		
		.u-m-t-20 {
		
			button {
				background-color: #fff;
				border: 0rpx;
				padding-right: 0rpx;
				padding-left: 0rpx;
			}
		
			button::after {
				border: none;
			}
		}
		
		.contact-btn {
			display: inline-block;
			position: absolute;
			width: 100%;
			background: salmon;
			opacity: 0;
		}
		.textcss {
			width: 100%;
			text-align: center;
			position: absolute;
			bottom: 30rpx;
			text-align: center;
			color: #828284;
		}
	}




</style>
